package com.rules.admin.json;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;

public class String2Long extends JsonDeserializer<Long> {
    public String2Long() {
    }

    public Long deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        return !StringUtils.isEmpty(parser.getText()) ? Long.valueOf(parser.getText()) : null;
    }
}
